#include <stdio.h>
struct
{
	char name[10];
	int a, MT, EN, PH, sum;
	double ave;
} stu[30] , temp;
int main()
{
	int i, j, n;
	
	do
	{
        printf("请输入班里一共几人");
		scanf("%d" , &n);
	} while ( n > 30 );
	for ( i = 0 ; i < n ; i++ )
	{
		printf("请输入第%d个人的姓名:" , i + 1);
		stu[i].a = i + 1;
		scanf("%s" , stu[i].name);
		printf("请分别输入该同学的数学成绩MT，英语成绩EN，物理成绩PH\n");
		scanf("%d%d%d" , &stu[i].MT , &stu[i].EN , &stu[i].PH);
		stu[i].sum = stu[i].MT + stu[i].EN + stu[i].PH;
		stu[i].ave = stu[i].sum / n;
	}
	for ( i = 0 ; i < n ; i++ )
	{
		for ( j = i + 1 ; j < n ; j++ )
		{
			if ( stu[i].sum < stu[j].sum )
			{
				temp = stu[i];
				stu[i] = stu[j];
				stu[j] = temp;
			}
		}
	}
	printf("编号\t姓名\t数学\t英语\t物理\t总分\t平均分\t名次\n");
	for ( i = 0 ; i < n ; i++ )
		printf("%d\t%s\t%d\t%d\t%d\t%d\t%.2lf\t%d\n" , stu[i].a , stu[i].name , stu[i].MT , stu[i].EN , stu[i].PH , stu[i].sum , stu[i].ave , i + 1);
	return 0;
}